<?php

namespace App\Repositories\Impl;

use App\Models\MeetPerson;
use App\Repositories\Contracts\MeetPersonRepository;
use App\Repositories\Transformers\MeetPersonListTransformer;

class MeetPersonRepositoryImpl implements MeetPersonRepository
{
    public function paginate($perPage, $filter)
    {
        $news = MeetPerson::where($filter)->paginate($perPage);
        $result = fractal($news, new MeetPersonListTransformer());

        return $result->toArray();

    }

    public function find($id, $columns = ['*'])
    {
        return MeetPerson::find($id, $columns);
    }

    public function findInWhere($column, $data)
    {
        return MeetPerson::whereIn($column, $data)->get();

    }

    public function findByFilter($filter, $columns = ['*'])
    {
        return MeetPerson::where($filter)->first($columns);
    }

    public function store($data)
    {
        return MeetPerson::create($data);
    }

    public function update($data, $id)
    {
        return MeetPerson::whereId($id)->updateOrCreate($data);
    }

    public function updateByFilter($data, $where)
    {
        return MeetPerson::where($where)->update($data);
    }

    public function delete($id)
    {
        return MeetPerson::whereId($id)->delete();
    }
}
